import { MANAGER_USER_QUERY } from "./types";
import ajax from "@/utils/ajax_ts/api"; // tsconfig.json文件中检测类型
import { ActionTree } from "vuex";

/**
 * 所有的 axios 放到 vuex 的 actions 中做统一管理,
 * 此方法全部resolve进行commit提交
 */
const actions: ActionTree<any, any> = {
    async [MANAGER_USER_QUERY]({ commit }, payload) {
        const res = await ajax.post("/systemSetting/usermanager/query", payload); // const { res } :any = await ajax.post('', payload);
        // 返回值的类型是types文件夹中的axios.d.ts
        return new Promise((resolve, reject) => {
            if (res.status === 200 && res.data.code == 0) {
                resolve(res.data.datas);
            } else {
                reject(res.data.message);
            }
        });
    }
};

export default actions;
